
from base.base import Base
from selenium.webdriver.common.by import By
from time import sleep


class GeneralProlemPage(Base):

    goodsmanager = (By.XPATH,'//span[text()="商场管理"]')
    def clickgoodsmanager(self):
        self.loc_ele(self.goodsmanager).click()

    generalprolem = (By.XPATH, '//span[text()="通用问题"]')

    def clickgeneralprolem(self):
        self.loc_ele(self.generalprolem).click()

    addgenera = (By.CSS_SELECTOR,"#app > div > div.main-container > section > div > div.filter-container > button:nth-child(3) > span")

    def clickaddgenera(self):
        self.loc_ele(self.addgenera).click()

    proleminput = (By.CLASS_NAME,"el-input__inner")
    def inputprolemcontent(self,c):
        ele = self.loc_ele(self.proleminput)
        ele = ele[3]
        ele.send_keys(c)

    inputreply = (By.CLASS_NAME, "el-textarea__inner")

    def inputreplycontent(self, c):
        ele = self.loc_ele(self.inputreply)
        ele.send_keys(c)

    ensurebutton = (By.XPATH,'/html/body/div[1]/div/div[2]/section/div/div[4]/div/div[3]/div/button[2]/span')
    def clickensurebutton(self):
        self.loc_ele(self.ensurebutton).click()

    dy = (By.XPATH,'//table[@class="el-table__body"]/tbody/tr[1]/td[2]/div')
    def getdycontent(self):
        return self.loc_ele(self.dy).text
    dy2 = (By.CLASS_NAME,"el-form-item__error")
    def getdy2content(self):
        return self.loc_ele(self.dy2).text

    def addprolembusiness(self,q,r):
        self.clickgoodsmanager()
        sleep(1)
        self.clickgeneralprolem()
        sleep(1)
        self.clickaddgenera()
        self.inputprolemcontent(q)
        self.inputreplycontent(r)
        self.clickensurebutton()
        sleep(3)
